﻿<UserControl x:Class="JounceSilverlightDemo.Views.Login" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
             xmlns:Services="clr-namespace:Jounce.Framework.Services;assembly=Jounce" 
             xmlns:conv="clr-namespace:JounceSilverlightDemo.Converters"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
             mc:Ignorable="d" d:DesignWidth="540" d:DesignHeight="150">

    <Grid x:Name="LayoutRoot">
        <Grid Name="grdLogin" Height="100" Width="500" HorizontalAlignment="Stretch" VerticalAlignment="Center" >
            <Grid.Resources>
                <conv:VisibilityConverter x:Key="VisibilityConverter" />
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Name="lblUserName" Text="User name : " Grid.Row="0" Grid.Column="0" 
                       HorizontalAlignment="Right" VerticalAlignment="Center" CharacterSpacing="20" />
            <TextBox Name="txtUserName" Grid.Row="0" Grid.Column="1" Margin="5" 
                     HorizontalAlignment="Stretch" VerticalAlignment="Center" CharacterSpacing="20" 
                     Text="{Binding UserName, Mode=TwoWay}" />
            <TextBlock Name="lblUserPswd" Text="Password : " Grid.Row="1" Grid.Column="0" 
                       HorizontalAlignment="Right" VerticalAlignment="Center" CharacterSpacing="20" />
            <!-- Ref: http://wpftutorial.net/PasswordBox.html -->
            <PasswordBox Name="txtUserPswd" Grid.Row="1" Grid.Column="1" Margin="5" 
                         HorizontalAlignment="Stretch" VerticalAlignment="Center" CharacterSpacing="20" 
                         Password="{Binding UserPassword, Mode=TwoWay}" PasswordChar="$" />

            <StackPanel Name="stkLowerControls" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" 
                        HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
                <TextBlock Name="txtError" Width="350" Margin="5" Foreground="Red" FontWeight="Bold"
                           TextAlignment="Right" VerticalAlignment="Center"
                           Visibility="{Binding HasError, Converter={StaticResource VisibilityConverter}}"
                           Text="Login error! Please enter correct credentials.." />
                <Button Name="btnOK" Content="OK" Margin="5" Width="100" 
                        HorizontalAlignment="Right" VerticalAlignment="Center" 
                        Command="{Binding LoginCommand}" IsEnabled="{Binding IsLoginAllowed}" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
